﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Shorten.Core.Models
{
    public class LogItem
    {

        public enum ActionType
        {
            TryCreateButExists,
            TryCreateCustomButExists,
            Create,
            Get,
            Error
        };

        public DateTime time { get; set; }
        public ActionType action { get; set; }
        public string shortURL { get; set; }
        public string referrer { get; set; }
        public ShortenItems item { get; set; }

        public static IList<LogItem> GetAllItems()
        {
           //TODO - Implement this
            return null;
        }

        public static string AddToLog(ShortenItems item, LogItem.ActionType action, string optionalMessage)
        {
            //TOTO - Set the required info for logging/analytics
            //ShortenManagement.SaveRequest(null);

            //LogItem logItem = new LogItem();
            //logItem.item = item;
            //logItem.action = action;
            //logItem.time = DateTime.Now;
            //logItem.referrer = ""; //Need to get this somehow

            //LogHelper lh = new LogHelper();
            //lh.CreateEntry(logItem);

            //Return the value
            return item.ShortUrl;
        }

        /// <summary>
        /// Add the current Item to the Log
        /// </summary>
        /// <returns></returns>
        public string SaveToLog()
        {
            //TOTO - Set the required info for logging/analytics
            //ShortenManagement.SaveRequest(null);

            //LogItem logItem = new LogItem();
            //logItem.item = item;
            //logItem.action = action;
            //logItem.time = DateTime.Now;
            //logItem.referrer = ""; //Need to get this somehow

            //LogHelper lh = new LogHelper();
            //lh.CreateEntry(logItem);

            //Return the value
            return item.ShortUrl;
        }

    }
}
